<template>
    <div class="i-table-no-border">
        <Tabs value="1" @on-click="tabCustom" :animated="false">
            <TabPane name="1" :label="'全部('+totallist.all_num+')'">
                <Form ref="form" :model="createData">
                    <Row :gutter="24" type="flex">
                        <Col span="4">
                        <FormItem prop="start_time">
                            <DatePicker type="daterange" v-model="createData.start_time" placeholder="日期选择"
                                @on-change="Submits" />
                        </FormItem>
                        </Col>
                        <Col span="4">
                        <FormItem prop="keywords">
                            <Input @on-enter="handleSubmits(0)" v-model="createData.keywords"
                                placeholder="请输入患者姓名/手机号/诊疗号" />
                        </FormItem>
                        </Col>
                        <Col span="4">
                        <FormItem prop="belong_assistant_id">
                            <Select v-model="createData.belong_assistant_id" placeholder="所属客服" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.member_customer_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4">
                        <FormItem prop="outpatient_type_id">
                            <Select v-model="createData.outpatient_type_id" placeholder="就诊类型" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.outpatient_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4">
                        <FormItem prop="effect_type_id">
                            <Select v-model="createData.effect_type_id" placeholder="效果类型" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.effect_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="risk_type_id">
                            <Select v-model="createData.risk_type_id" placeholder="风控类型" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.risk_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="clinic_assess_id">
                            <Select v-model="createData.clinic_id" placeholder="请选择诊室" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.clinic_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="body_parts_ids">
                            <Select v-model="createData.body_parts_ids" placeholder="请选择部位" filterable multiple
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.body_parts_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="tags_ids">
                            <Select v-model="createData.tags_ids" filterable multiple placeholder="请选择标签"
                                @on-change="handleSubmits(0)">
                                <OptionGroup v-for="item in baseInfo.tags_list" :key="item.id" :label="item.name">
                                    <Option v-for="items in item.children" :value="items.id" :key="items.id" :disabled="+items.status === 0">
                                        {{ items.name }}</Option>
                                </OptionGroup>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="tags_ids">
                            <Select v-model="createData.patient_diseases_id" placeholder="请选择病种" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.patient_diseases_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col span="4" v-show="disabledStatus">
                        <FormItem prop="patient_diseases_id">
                            <div style="position: relative;">
                                <Select v-model="createData.fault_diagnosis_type" placeholder="请选择断诊次数" :clearable="true"
                                    @on-change="handleSubmits(0)">
                                    <Option :value="1">1次</Option>
                                    <Option :value="2">2次</Option>
                                    <Option :value="3">3次</Option>
                                    <Option :value="4">3次以上</Option>
                                </Select>
                            </div>
                        </FormItem>
                        </Col>
                        <Col v-bind="grid" class="ivu-text-right">
                        <Button type="primary" @click="handleSubmit(0)">查询</Button>
                        <Button class="ivu-ml-8" @click="handleSubmit(1)">重置</Button>
                        <a href="javascript:;" class="modeLeft" @click="modeStatus">
                            <span>{{ disabledStatus ? '收起' : '展开' }}</span>
                            <Icon v-if="!disabledStatus" type="ios-arrow-down" />
                            <Icon v-else type="ios-arrow-up" />
                        </a>
                        </Col>
                    </Row>
                </Form>
                <Table size="small" ref="table" :columns="columns" :data="data" :loading="loading"
                    @on-sort-change="handleChangeSort">
                    <template slot-scope="{ row }" slot="info">
                        <a href="javaScript:;" @click="handleDetailPatient(row)">{{ row.name }} , {{ row.age }} ,
                            {{ row.gender_str }}</a>
                    </template>
                    <template slot-scope="{ row }" slot="diagnosis">
                        <Tag class="blueStatus" v-if="row.outpatient_name" color="blue">{{ row.outpatient_name }}</Tag>
                    </template>
                    <template slot-scope="{ row }" slot="label">
                        <Poptip word-wrap trigger="hover" placement="right" width="400">
                            <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index" v-if="index < 3">
                                {{ item }}</Tag>
                            <div slot="content">
                                <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index">{{ item }}</Tag>
                            </div>
                        </Poptip>
                    </template>
                    <template slot-scope="{ row }" slot="next_revisiting_time_str">
                        <div v-if="!row.show" class="DatePicker " @click="aaa" @dblclick="DatePicker (row)">
                            {{row.next_revisiting_time_str === '' ? '&#12288;' : row.next_revisiting_time_str}}
                        </div>
                        <DatePicker :transfer="true" v-if="row.show" v-model="next_revisiting_time_strs"
                            placement="bottom" :options="options6" confirm type="date" placeholder="请选择下次复诊时间"
                            style="width: 80px" @on-ok="confirm(row)" @on-clear="OnClear(row)"></DatePicker>
                    </template>
                    <template slot-scope="{ row }" slot="patient_card_id">
                        <span v-if="row.patient_card_id">
                            <span v-if="row.patient_card_id.length < 15">
                                {{row.patient_card_id}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.patient_card_id">
                                {{row.patient_card_id.substring(0, 15)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="belong_member_name">
                        <span v-if="row.belong_member_name">
                            <span v-if="row.belong_member_name.length < 4">
                                {{row.belong_member_name}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.belong_member_name">
                                {{row.belong_member_name.substring(0, 4)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="channel">
                        <Badge status="success" :text="row.source_name" />
                    </template>
                    <template slot-scope="{ row, index }" slot="action">
                        <a @click="handleOpenDrawer(row.id)">编辑</a>
                        <Divider type="vertical" />
                        <a @click="handleOpenSubmit(row)">回访</a>
                    </template>
                    <!-- <template slot-scope="{ row }" slot="remark">
                        <Tooltip :content="row.remark" :delay="500" placement="left" theme="light" max-width="500"
                            :word-wrap="true" :transfer="true">
                            <span
                                style="font-size: 12px">{{  row.remark && row.remark.length > 14 ? row.remark.slice(0, 14) +  '...' : row.remark }}</span>
                        </Tooltip>
                    </template> -->
                </Table>
                <div class="ivu-mt ivu-text-center">
                    <Page :total="total" :current.sync="realData.page" show-total show-elevator transfer
                        :page-size="realData.pageSize" @on-change="handleChangePage" :page-size-opts="pageOpts"
                        show-sizer @on-page-size-change="handleChangePageSize" />
                </div>
            </TabPane>
            <TabPane name="2" :label="'已到('+totallist.arrive_num+')'">
                <Form ref="form" :model="createData">
                    <Row :gutter="24" type="flex">
                        <Col>
                        <RadioGroup v-model="phone" type="button" @on-change="handleChangeVisitType">
                            <Radio label="1">
                                今日
                            </Radio>
                            <Radio label="2">
                                昨日
                            </Radio>
                        </RadioGroup>
                        </Col>
                        <Col>
                        <FormItem prop="start_time">
                            <DatePicker @on-change="Submits" type="daterange" :options="options4" v-model="start_time"
                                placeholder="请选择来院日期" />
                        </FormItem>
                        </Col>
                        <Col span="5">
                        <FormItem prop="keywords">
                            <Input @on-enter="handleSubmits(0)" @on-blur="handleSubmits(0)"
                                v-model="createData.keywords" placeholder="请输入患者姓名/手机号/诊疗号" />
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="belong_assistant_id">
                            <Select v-model="createData.belong_assistant_id" @on-change="handleSubmits(0)"
                                placeholder="所属客服" :clearable="true">
                                <Option v-for="item in baseInfo.member_customer_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="outpatient_type_id">
                            <Select v-model="createData.outpatient_type_id" @on-change="handleSubmits(0)"
                                placeholder="就诊类型" :clearable="true">
                                <Option v-for="item in baseInfo.outpatient_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="clinic_assess_id">
                            <Select v-model="createData.clinic_id" placeholder="请选择诊室" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.clinic_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="patient_diseases_id">
                            <div style="position: relative;">
                                <Select v-model="createData.fault_diagnosis_type" placeholder="请选择断诊次数" :clearable="true"
                                    @on-change="handleSubmits(0)">
                                    <Option :value="1">1次</Option>
                                    <Option :value="2">2次</Option>
                                    <Option :value="3">3次</Option>
                                    <Option :value="4">3次以上</Option>
                                </Select>
                            </div>
                        </FormItem>
                        </Col>
                    </Row>
                </Form>
                <Table size="small" ref="table" :columns="columns" :data="beenList" :loading="loading"
                    @on-sort-change="handleChangeSort">
                    <template slot-scope="{ row }" slot="info">
                        <a href="javaScript:;" @click="handleDetailPatient(row)">{{ row.name }} , {{ row.age }} ,
                            {{ row.gender_str }}</a>
                    </template>
                    <template slot-scope="{ row }" slot="diagnosis">
                        <Tag class="blueStatus" v-if="row.outpatient_name" color="blue">{{ row.outpatient_name }}</Tag>
                    </template>
                    <template slot-scope="{ row }" slot="label">
                        <Poptip word-wrap trigger="hover" placement="right" width="400">
                            <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index" v-if="index < 3">
                                {{ item }}</Tag>
                            <div slot="content">
                                <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index">{{ item }}</Tag>
                            </div>
                        </Poptip>
                    </template>
                    <template slot-scope="{ row }" slot="patient_card_id">
                        <span v-if="row.patient_card_id">
                            <span v-if="row.patient_card_id.length < 15">
                                {{row.patient_card_id}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.patient_card_id">
                                {{row.patient_card_id.substring(0, 15)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="next_revisiting_time_str">
                        <div v-if="!row.show" class="DatePicker " @click="aaa" @dblclick="DatePicker (row)">
                            {{row.next_revisiting_time_str === '' ? '&#12288;' : row.next_revisiting_time_str}}
                        </div>
                        <DatePicker :transfer="true" v-if="row.show" v-model="next_revisiting_time_strs"
                            placement="bottom" :options="options6" confirm type="date" placeholder="请选择下次复诊时间"
                            style="width: 80px" @on-ok="confirm(row)" @on-clear="OnClear(row)"></DatePicker>
                    </template>
                    <template slot-scope="{ row }" slot="belong_member_name">
                        <span v-if="row.belong_member_name">
                            <span v-if="row.belong_member_name.length < 4">
                                {{row.belong_member_name}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.belong_member_name">
                                {{row.belong_member_name.substring(0, 4)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="channel">
                        <Badge status="success" :text="row.source_name" />
                    </template>
                    <template slot-scope="{ row, index }" slot="action">
                        <a @click="handleOpenDrawer(row.id)">编辑</a>
                        <Divider type="vertical" />
                        <a @click="handleOpenSubmit(row)">回访</a>
                    </template>
                    <template slot-scope="{ row }" slot="remark">
                        <Tooltip :content="row.remark" :delay="500" placement="left" theme="light" max-width="500"
                            :word-wrap="true" :transfer="true">
                            <span
                                style="font-size: 12px">{{  row.remark && row.remark.length > 14 ? row.remark.slice(0, 14) +  '...' : row.remark }}</span>
                        </Tooltip>
                    </template>
                </Table>
                <div class="ivu-mt ivu-text-center">
                    <Page :total="beenList.total" :current.sync="realData.page" show-total show-elevator transfer
                        :page-size="realData.pageSize" @on-change="handleChangePage" :page-size-opts="pageOpts"
                        show-sizer @on-page-size-change="handleChangePageSize" />
                </div>
            </TabPane>
            <TabPane name="3" :label="'预到('+totallist.order_arrive_num+')'">
                <Form ref="form" :model="createData">
                    <Row :gutter="24" type="flex">
                        <Col>
                        <RadioGroup v-model="advance" type="button" @on-change="handleChangeVisitType">
                            <Radio label="1">
                                今日
                            </Radio>
                            <Radio label="4">
                                明日
                            </Radio>
                            <Radio label="3">
                                周
                            </Radio>
                        </RadioGroup>
                        </Col>
                        <Col>
                        <FormItem prop="start_time">
                            <DatePicker type="daterange" @on-change="Submits" :options="options3" v-model="start_time"
                                placeholder="请选择预到日期" />
                        </FormItem>
                        </Col>
                        <Col span="5">
                        <FormItem prop="keywords">
                            <Input @on-enter="handleSubmits(0)" @on-blur="handleSubmits(0)"
                                v-model="createData.keywords" placeholder="请输入患者姓名/手机号/诊疗号" />
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="belong_assistant_id">
                            <Select v-model="createData.belong_assistant_id" @on-change="handleSubmits(0)"
                                placeholder="所属客服" :clearable="true">
                                <Option v-for="item in baseInfo.member_customer_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="outpatient_type_id">
                            <Select v-model="createData.outpatient_type_id" @on-change="handleSubmits(0)"
                                placeholder="就诊类型" :clearable="true">
                                <Option v-for="item in baseInfo.outpatient_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="clinic_assess_id">
                            <Select v-model="createData.clinic_id" placeholder="请选择诊室" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.clinic_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="patient_diseases_id">
                            <div style="position: relative;">
                                <Select v-model="createData.fault_diagnosis_type" placeholder="请选择断诊次数" :clearable="true"
                                    @on-change="handleSubmits(0)">
                                    <Option :value="1">1次</Option>
                                    <Option :value="2">2次</Option>
                                    <Option :value="3">3次</Option>
                                    <Option :value="4">3次以上</Option>
                                </Select>
                            </div>
                        </FormItem>
                        </Col>
                    </Row>
                </Form>
                <Table size="small" ref="table" :columns="columns" :data="OrderList" :loading="loading"
                    @on-sort-change="handleChangeSort">
                    <template slot-scope="{ row }" slot="info">
                        <a href="javaScript:;" @click="handleDetailPatient(row)">{{ row.name }} , {{ row.age }} ,
                            {{ row.gender_str }}</a>
                    </template>
                    <template slot-scope="{ row }" slot="diagnosis">
                        <Tag class="blueStatus" v-if="row.outpatient_name" color="blue">{{ row.outpatient_name }}</Tag>
                    </template>
                    <template slot-scope="{ row }" slot="label">
                        <Poptip word-wrap trigger="hover" placement="right" width="400">
                            <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index" v-if="index < 3">
                                {{ item }}</Tag>
                            <div slot="content">
                                <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index">{{ item }}</Tag>
                            </div>
                        </Poptip>
                    </template>
                    <template slot-scope="{ row }" slot="patient_card_id">
                        <span v-if="row.patient_card_id">
                            <span v-if="row.patient_card_id.length < 15">
                                {{row.patient_card_id}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.patient_card_id">
                                {{row.patient_card_id.substring(0, 15)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="next_revisiting_time_str">
                        <div v-if="!row.show" class="DatePicker " @click="aaa" @dblclick="DatePicker (row)">
                            {{row.next_revisiting_time_str === '' ? '&#12288;' : row.next_revisiting_time_str}}
                        </div>
                        <DatePicker :transfer="true" v-if="row.show" v-model="next_revisiting_time_strs"
                            placement="bottom" :options="options6" confirm type="date" placeholder="请选择下次复诊时间"
                            style="width: 80px" @on-ok="confirm(row)" @on-clear="OnClear(row)"></DatePicker>
                    </template>
                    <template slot-scope="{ row }" slot="belong_member_name">
                        <span v-if="row.belong_member_name">
                            <span v-if="row.belong_member_name.length < 4">
                                {{row.belong_member_name}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.belong_member_name">
                                {{row.belong_member_name.substring(0, 4)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="channel">
                        <Badge status="success" :text="row.source_name" />
                    </template>
                    <template slot-scope="{ row, index }" slot="action">
                        <a @click="handleOpenDrawer(row.id)">编辑</a>
                        <Divider type="vertical" />
                        <a @click="handleOpenSubmit(row)">回访</a>
                    </template>
                    <template slot-scope="{ row }" slot="remark">
                        <Tooltip :content="row.remark" :delay="500" placement="left" theme="light" max-width="500"
                            :word-wrap="true" :transfer="true">
                            <span
                                style="font-size: 12px">{{  row.remark && row.remark.length > 14 ? row.remark.slice(0, 14) +  '...' : row.remark }}</span>
                        </Tooltip>
                    </template>
                </Table>
                <div class="ivu-mt ivu-text-center">
                    <Page :total="total" :current.sync="realData.page" show-total show-elevator transfer
                        :page-size="realData.pageSize" @on-change="handleChangePage" :page-size-opts="pageOpts"
                        show-sizer @on-page-size-change="handleChangePageSize" />
                </div>
            </TabPane>
            <TabPane name="4" :label="'过期未到('+totallist.unarrive_num+')'">
                <Form ref="form" :model="createData">
                    <Row :gutter="24" type="flex">
                        <Col>
                        <RadioGroup v-model="BackTo" type="button" @on-change="handleChangeVisitType">
                            <Radio label="2">
                                昨日
                            </Radio>
                            <Radio label="5">
                                周
                            </Radio>
                        </RadioGroup>
                        </Col>
                        <Col>
                        <FormItem prop="start_time">
                            <DatePicker type="daterange" @on-change="Submits" :options="options5" v-model="start_time"
                                placeholder="请选择过期日期" />
                        </FormItem>
                        </Col>
                        <Col span="5">
                        <FormItem prop="keywords">
                            <Input @on-enter="handleSubmits(0)" v-model="createData.keywords"
                                placeholder="请输入患者姓名/手机号/诊疗号" />
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="belong_assistant_id">
                            <Select v-model="createData.belong_assistant_id" @on-change="handleSubmits(0)"
                                placeholder="所属客服" :clearable="true">
                                <Option v-for="item in baseInfo.member_customer_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="outpatient_type_id">
                            <Select v-model="createData.outpatient_type_id" @on-change="handleSubmits(0)"
                                placeholder="就诊类型" :clearable="true">
                                <Option v-for="item in baseInfo.outpatient_type_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="clinic_assess_id">
                            <Select v-model="createData.clinic_id" placeholder="请选择诊室" :clearable="true"
                                @on-change="handleSubmits(0)">
                                <Option v-for="item in baseInfo.clinic_list" :key="item.id" :value="item.id" :disabled="+item.status === 0">
                                    {{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col>
                        <FormItem prop="patient_diseases_id">
                            <div style="position: relative;">
                                <Select v-model="createData.fault_diagnosis_type" placeholder="请选择断诊次数" :clearable="true"
                                    @on-change="handleSubmits(0)">
                                    <Option :value="1">1次</Option>
                                    <Option :value="2">2次</Option>
                                    <Option :value="3">3次</Option>
                                    <Option :value="4">3次以上</Option>
                                </Select>
                            </div>
                        </FormItem>
                        </Col>
                    </Row>
                </Form>
                <Table size="small" ref="table" :columns="columns" :data="UnarriveList" :loading="loading"
                    @on-sort-change="handleChangeSort">
                    <template slot-scope="{ row }" slot="info">
                        <a href="javaScript:;" @click="handleDetailPatient(row)">{{ row.name }} , {{ row.age }} ,
                            {{ row.gender_str }}</a>
                    </template>
                    <template slot-scope="{ row }" slot="diagnosis">
                        <Tag class="blueStatus" v-if="row.outpatient_name" color="blue">{{ row.outpatient_name }}</Tag>
                    </template>
                    <template slot-scope="{ row }" slot="next_revisiting_time_str">
                        <div v-if="!row.show" class="DatePicker " @click="aaa" @dblclick="DatePicker (row)">
                            {{row.next_revisiting_time_str === '' ? '&#12288;' : row.next_revisiting_time_str}}
                        </div>
                        <DatePicker :transfer="true" v-if="row.show" v-model="next_revisiting_time_strs"
                            placement="bottom" :options="options6" confirm type="date" placeholder="请选择下次复诊时间"
                            style="width: 80px" @on-ok="confirm(row)" @on-clear="OnClear(row)"></DatePicker>
                    </template>
                    <template slot-scope="{ row }" slot="label">
                        <Poptip word-wrap trigger="hover" placement="right" width="400">
                            <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index" v-if="index < 3">
                                {{ item }}</Tag>
                            <div slot="content">
                                <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index">{{ item }}</Tag>
                            </div>
                        </Poptip>
                    </template>
                    <template slot-scope="{ row }" slot="patient_card_id">
                        <span v-if="row.patient_card_id">
                            <span v-if="row.patient_card_id.length < 15">
                                {{row.patient_card_id}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.patient_card_id">
                                {{row.patient_card_id.substring(0, 15)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="belong_member_name">
                        <span v-if="row.belong_member_name">
                            <span v-if="row.belong_member_name.length < 4">
                                {{row.belong_member_name}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.belong_member_name">
                                {{row.belong_member_name.substring(0, 4)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="channel">
                        <Badge status="success" :text="row.source_name" />
                    </template>
                    <template slot-scope="{ row, index }" slot="action">
                        <a @click="handleOpenDrawer(row.id)">编辑</a>
                        <Divider type="vertical" />
                        <a @click="handleOpenSubmit(row)">回访</a>
                    </template>
                    <template slot-scope="{ row }" slot="remark">
                        <Tooltip :content="row.remark" :delay="500" placement="left" theme="light" max-width="500"
                            :word-wrap="true" :transfer="true">
                            <span
                                style="font-size: 12px">{{  row.remark && row.remark.length > 14 ? row.remark.slice(0, 14) +  '...' : row.remark }}</span>
                        </Tooltip>
                    </template>
                </Table>
                <div class="ivu-mt ivu-text-center">
                    <Page :total="total" :current.sync="realData.page" show-total show-elevator transfer
                        :page-size="realData.pageSize" @on-change="handleChangePage" :page-size-opts="pageOpts"
                        show-sizer @on-page-size-change="handleChangePageSize" />
                </div>
            </TabPane>
        </Tabs>
        <edit-patient ref="editPatient" @ok="getData" />
        <table-model ref="editModel" @close="closeEdit" />
        <Drawer :closable="false" v-model="showTetailDrawer" width="1000" class="edtailDrawers"  >
            <detailDrawer :editType="edit_type" v-if="patientId&&showTetailDrawer" :patientId="patientId">
            </detailDrawer>
        </Drawer>
    </div>
</template>
<script>
    import { serveList, GetArriveList, GetOrderArriveList, GetUnarriveList, updateNextRevisitingTime } from '@/api/patient'
    import tableModel from '@/components/visitModel/table-model';
    import EditPatient from '../patient-list/modules/editPatient'
    import { mapActions } from 'vuex';
    import detailDrawer from '../patient-detail/index.vue'

    import dayjs from 'dayjs'
    import { getFirstDayOfWeek, getFirstDayOnWeek, getFirstMonthOnWeek } from '@/utils/datetime';
    export default {
        components: {
            EditPatient,
            tableModel,
            detailDrawer
        },
        data() {
            return {
                patientId: null,
                edit_type: 1,
                showTetailDrawer: false,
                spinShow: true,
                e: [],
                name: '1',
                BackTo: '2',
                advance: '1',
                phone: '1',
                start_time: [],
                disabledStatus: false,
                createData: {
                    start_time: [],
                    end_time: '',
                    keywords: '',
                    belong_assistant_id: '',
                    outpatient_type_id: '',
                    effect_type_id: '',
                    risk_type_id: '',
                    clinic_assess_id: '',
                    body_parts_ids: [],
                    clinic_id: '',
                    tags_ids: [],
                    sort_last_revisiting_type: 0,
                    sort_next_revisiting_type: 0,
                    sort_last_callback_type: 0,
                    sort_next_callback_type: 0,
                    sort_revisiting_type: 0,
                    sort_callback_type: 0,
                    sort_missed_type: 0,
                    page: 1,
                    pageSize: 10,
                    patient_diseases_id: '',
                    fault_diagnosis_type: ''
                },
                realData: {
                    start_time: [],
                    end_time: '',
                    keywords: '',
                    belong_assistant_id: '',
                    outpatient_type_id: '',
                    effect_type_id: '',
                    clinic_id: '',
                    risk_type_id: '',
                    clinic_assess_id: '',
                    body_parts_ids: [],
                    tags_ids: [],
                    sort_last_revisiting_type: 0,
                    sort_next_revisiting_type: 0,
                    sort_last_callback_type: 0,
                    sort_next_callback_type: 0,
                    sort_revisiting_type: 0,
                    sort_callback_type: 0,
                    sort_missed_type: 0,
                    page: 1,
                    pageSize: 10,
                    fault_diagnosis_type: ''
                },
                baseInfo: {
                    body_parts_list: [],
                    tags_list: [],
                    member_list: [],
                    effect_type_list: [],
                    risk_type_list: [],
                    clinic_assess_list: [],
                    outpatient_type_list: [],
                    patient_diseases_list: []
                },
                total: 0,
                pageOpts: [10, 20, 30, 50],
                grid: {
                    xl: 4,
                    lg: 8,
                    md: 12,
                    sm: 24,
                    xs: 24
                },
                loading: false,
                columns: [
                    {
                        title: '基本信息',
                        slot: 'info',
                        minWidth: 130,
                        fixed: 'left'
                    },
                    {
                        title: '诊疗号',
                        key: 'patient_card_id',
                        slot: 'patient_card_id',
                        minWidth: 110
                    },
                    {
                        title: '上次到诊',
                        key: 'last_revisiting_time_str',
                        sortable: true,
                        minWidth: 110
                    },
                    {
                        title: '未到诊天数',
                        key: 'missed_days',
                        // sortable: true,
                        sortable: 'custom',
                        minWidth: 115
                    },
                    {
                        title: '下次复诊',
                        key: 'next_revisiting_time_str',
                        slot: 'next_revisiting_time_str',
                        sortable: true,
                        minWidth: 110
                    },
                    {
                        title: '复诊次数',
                        key: 'revisiting_count',
                        // sortable: true,
                        sortable: 'custom',
                        minWidth: 110
                    },
                    {
                        title: '断诊次数',
                        key: 'fault_diagnosis_count',
                        // sortable: true,
                        // sortable: 'custom',
                        minWidth: 100
                    },
                    {
                        title: '上次回访时间',
                        key: 'last_callback_time_str',
                        sortable: true,
                        minWidth: 150
                    },
                    {
                        title: '下次回访时间',
                        key: 'next_callback_time_str',
                        sortable: true,
                        minWidth: 150
                    },
                    {
                        title: '回访次数',
                        key: 'callback_count',
                        // sortable: true,
                        sortable: 'custom',
                        minWidth: 110
                    },
                    {
                        title: '患者标签',
                        slot: 'label',
                        minWidth: 180
                    },
                    {
                        title: '就诊类型',
                        slot: 'diagnosis',
                        minWidth: 100
                    },
                    {
                        title: '地区',
                        key: 'city_name',
                        minWidth: 150
                    },
                    {
                        title: '备注',
                        minWidth: 120,
                        ellipsis: true,
                        tooltip: true,
                        key: 'remark'
                    },
                    {
                        title: '来源',
                        minWidth: 120,
                        slot: 'channel'
                    },
                    {
                        title: '诊室',
                        key: 'clinic_name',
                        minWidth: 80
                    },
                    {
                        title: '归属人',
                        key: 'belong_member_name',
                        slot: 'belong_member_name',
                        minWidth: 120
                    },
                    {
                        title: '病种',
                        key: 'diseases_name',
                        minWidth: 120
                    },
                    {
                        title: '操作',
                        minWidth: 110,
                        slot: 'action',
                        fixed: 'right'
                    }
                ],
                data: [],
                typeList: [],
                labelList: [],
                nowDayTime: '',
                nowWeekStart: '',
                nowWeekEnd: '',

                nowMonthStart: '',
                nowMonthEnd: '',
                yesterdayT: '',
                beenList: [],
                OrderList: [],
                yesterday: '',
                UnarriveList: [],
                yesterdays: '',
                options3: {
                    disabledDate(date) {
                        return date && date.valueOf() < Date.now() - 86400000;
                    }
                },
                options4: {
                    disabledDate(date) {
                        return date && date.valueOf() > Date.now();
                    }
                },
                options5: {
                    disabledDate(date) {
                        return date && date.valueOf() > Date.now() - 86400000;
                    }
                },
                yestweek: '',
                options6: {
                    disabledDate(date) {
                        return date && date.valueOf() < Date.now() - 86400000;
                    }
                },
                row: {
                    show: false
                },
                next_revisiting_time_strs: '',
                totallist: {
                    all_num: 0,
                    arrive_num: 0,
                    order_arrive_num: 0,
                    unarrive_num: 0
                }
            }
        },
        created() {
            this.realData.sort_next_revisiting_type = 0
            this.realData.sort_last_callback_type = 0
            this.realData.sort_next_callback_type = 0
            this.realData.sort_revisiting_type = 0
            this.realData.sort_missed_type = 0
            this.realData.sort_callback_type = 0
            this.realData.sort_last_revisiting_type = 0
            let jumpPage = window.localStorage.getItem('jumpDetail')
            if (jumpPage) {
                let parsePage = JSON.parse(jumpPage)
                this.realData.belong_assistant_id = parsePage.belong.toString()
                this.createData.belong_assistant_id = parsePage.belong.toString()
            }
            this.getData()
            this.getNowDay()
        },
        destroyed() {
            window.localStorage.removeItem('jumpDetail')
        },
        methods: {
            closeDrawer() {
                switch (this.name) {
                    case "1": {
                        // console.log(this.name)
                        this.getData()
                    };
                        break;
                    case "2": {
                        this.getBeen()
                        // console.log(this.name)
                    };
                        break;
                    case "3": {
                        this.GetOrder()
                        // console.log(this.name)
                    };
                        break;
                    case "4": {
                        this.GetUnarrive()
                        // console.log(this.name)

                    };
                }
            },
            ...mapActions('admin/page', ['setPatientDetail']),
            // 清除
            OnClear(row) {
                row.show = !row.show
            },
            // 确认日期
            confirm(row) {
                if (row.next_revisiting_time_str === '') {
                    row.next_revisiting_time_str = dayjs(new Date()).format('YYYY-MM-DD')
                    const config = {
                        id: row.id,
                        next_revisiting_time: row.next_revisiting_time_str
                    }
                    updateNextRevisitingTime(config).then(res => {
                        row.show = !row.show
                    })
                } else {
                    this.next_revisiting_time_strs = dayjs(this.next_revisiting_time_strs).format('YYYY-MM-DD')
                    const config = {
                        id: row.id,
                        next_revisiting_time: this.next_revisiting_time_strs
                    }
                    updateNextRevisitingTime(config).then(res => {
                        row.next_revisiting_time_str = this.next_revisiting_time_strs
                        row.show = !row.show
                    })
                }
            },
            // 单机事件
            aaa() {
                this.row.next_revisiting_time_strs = dayjs(this.row.next_revisiting_time_strs).format('YYYY-MM-DD')
                this.row.show = false
            },
            // 双击事件
            DatePicker(e) {
                this.next_revisiting_time_strs = e.next_revisiting_time_str
                this.row = e
                e.show = !e.show
            },
            getNowDay() {
                const now = new Date()
                const nowMonth = now.getMonth()
                const nowYear = now.getFullYear()
                this.nowDayTime = now
                const time = (new Date()).getTime() - (24 * 60 * 60 * 1000)
                const times = (new Date()).getTime() + (7 * 24 * 60 * 60 * 1000)
                const etime = (new Date()).getTime() + (24 * 60 * 60 * 1000)
                const week = (new Date()).getTime() - (7 * 24 * 60 * 60 * 1000)
                this.yesterdayT = new Date(time)
                this.yesterday = new Date(times)
                this.yesterdays = new Date(etime)
                this.yestweek = new Date(week)
                this.nowMonthStart = new Date(nowYear, nowMonth, 1)
                this.nowMonthEnd = getFirstMonthOnWeek(new Date())
                this.nowWeekStart = getFirstDayOfWeek(new Date())
                this.nowWeekEnd = getFirstDayOnWeek(new Date())
                const nowYears = dayjs(this.nowDayTime).format('YYYY-MM-DD')
                this.nowDayTime = nowYears
                this.start_time = [this.nowDayTime, this.nowDayTime]
            },
            tabCustom(e) {
                this.createData =  {
                    start_time: [],
                    end_time: '',
                    keywords: '',
                    belong_assistant_id: '',
                    outpatient_type_id: '',
                    effect_type_id: '',
                    risk_type_id: '',
                    clinic_assess_id: '',
                    body_parts_ids: [],
                    clinic_id: '',
                    tags_ids: [],
                    sort_last_revisiting_type: 0,
                    sort_next_revisiting_type: 0,
                    sort_last_callback_type: 0,
                    sort_next_callback_type: 0,
                    sort_revisiting_type: 0,
                    sort_callback_type: 0,
                    sort_missed_type: 0,
                    page: 1,
                    pageSize: 10,
                    patient_diseases_id: '',
                    fault_diagnosis_type: ''
                },
                this.realData = {
                    start_time: [],
                    end_time: '',
                    keywords: '',
                    belong_assistant_id: '',
                    outpatient_type_id: '',
                    effect_type_id: '',
                    clinic_id: '',
                    risk_type_id: '',
                    clinic_assess_id: '',
                    body_parts_ids: [],
                    tags_ids: [],
                    sort_last_revisiting_type: 0,
                    sort_next_revisiting_type: 0,
                    sort_last_callback_type: 0,
                    sort_next_callback_type: 0,
                    sort_revisiting_type: 0,
                    sort_callback_type: 0,
                    sort_missed_type: 0,
                    page: 1,
                    pageSize: 10,
                    fault_diagnosis_type: ''
                },
                this.name = e
                if (e === '1') {
                    this.getData()
                } else if (e === '2') {
                    this.getNowDay()
                    this.getBeen()
                    this.phone = '1'
                } else if (e === '3') {
                    this.getNowDay()
                    this.GetOrder()
                    this.advance = '1'
                } else if (e === '4') {
                    this.BackTo = '2'
                    this.getNowDay()
                    const nowYearStart = dayjs(this.yesterdayT).format('YYYY-MM-DD')
                    this.start_time = [nowYearStart, nowYearStart]
                    this.GetUnarrive()
                }
            },
            // 切换日期
            handleChangeVisitType(e) {
                switch (e) {
                    case '1':
                        const nowYears = dayjs(this.nowDayTime).format('YYYY-MM-DD')
                        this.nowDayTime = nowYears
                        this.start_time = [this.nowDayTime, this.nowDayTime]
                        break
                    case '2':
                        const nowYearStart = dayjs(this.yesterdayT).format('YYYY-MM-DD')
                        this.start_time = [nowYearStart, nowYearStart]
                        break
                    case '3':
                        const yesterday = dayjs(this.yesterday).format('YYYY-MM-DD')
                        this.start_time = [this.nowDayTime, yesterday]
                        break
                    case '4':
                        const yesterdays = dayjs(this.yesterdays).format('YYYY-MM-DD')
                        this.start_time = [yesterdays, yesterdays]
                        break
                    case '5':
                        this.start_time = [this.yestweek, this.yesterdayT]
                        break
                    default:
                        this.start_time = [this.nowDayTime, this.nowDayTime]
                        this.switchTime = '1'
                        break
                }
                if (this.name === '2') {
                    this.getBeen()
                } else if (this.name === '3') {
                    this.GetOrder()
                } else if (this.name === '4') {
                    this.GetUnarrive()
                }
            },
            GetOrder() {
                if (this.start_time[0] !== undefined && this.start_time[0] !== '') {
                    this.start_time = [dayjs(this.start_time[0]).format('YYYY-MM-DD'), dayjs(this.start_time[1]).format('YYYY-MM-DD')]
                } else {
                    this.start_time = ['', '']
                }
                this.loading = true
                const config = {
                    edit_type: '1',
                    start_time: this.start_time[0],
                    end_time: this.start_time[1],
                    clinic_id: this.createData.clinic_id,
                    page: this.realData.page,
                    pageSize: this.realData.pageSize,
                    keywords: this.createData.keywords || '',
                    outpatient_type_id: this.createData.outpatient_type_id || '',
                    belong_member_id: this.createData.belong_assistant_id || '',
                    sort_last_revisiting_type: this.realData.sort_last_revisiting_type,
                    sort_next_revisiting_type: this.realData.sort_next_revisiting_type,
                    sort_last_callback_type: this.realData.sort_last_callback_type,
                    sort_next_callback_type: this.realData.sort_next_callback_type,
                    sort_revisiting_type: this.realData.sort_revisiting_type,
                    sort_callback_type: this.realData.sort_callback_type,
                    sort_missed_type: this.realData.sort_missed_type,
                    fault_diagnosis_type: this.realData.fault_diagnosis_type
                }
                GetOrderArriveList(config).then(res => {
                    this.totallist.all_num = res.tab_totals.all_num
                    this.totallist.arrive_num = res.tab_totals.arrive_num
                    this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                    this.totallist.unarrive_num = res.tab_totals.unarrive_num
                    this.OrderList = res.list
                    for (let i = 0; i < this.OrderList.length; i++) {
                        this.$set(this.OrderList[i], 'show', false)
                    }
                    this.total = res.total
                    this.loading = false
                })
            },
            GetUnarrive() {
                if (this.start_time[0] !== undefined && this.start_time[0] !== '') {
                    this.start_time = [dayjs(this.start_time[0]).format('YYYY-MM-DD'), dayjs(this.start_time[1]).format('YYYY-MM-DD')]
                } else {
                    this.start_time = ['', '']
                }
                this.loading = true
                const config = {
                    edit_type: '1',
                    start_time: this.start_time[0],
                    end_time: this.start_time[1],
                    page: this.realData.page,
                    pageSize: this.realData.pageSize,
                    clinic_id: this.createData.clinic_id,
                    keywords: this.createData.keywords || '',
                    outpatient_type_id: this.createData.outpatient_type_id || '',
                    belong_member_id: this.createData.belong_assistant_id || '',
                    effect_type_id: this.createData.effect_type_id || '',
                    sort_last_revisiting_type: this.realData.sort_last_revisiting_type,
                    sort_next_revisiting_type: this.realData.sort_next_revisiting_type,
                    sort_last_callback_type: this.realData.sort_last_callback_type,
                    sort_next_callback_type: this.realData.sort_next_callback_type,
                    sort_revisiting_type: this.realData.sort_revisiting_type,
                    sort_callback_type: this.realData.sort_callback_type,
                    sort_missed_type: this.realData.sort_missed_type,
                    fault_diagnosis_type: this.realData.fault_diagnosis_type
                }
                GetUnarriveList(config).then(res => {
                    this.totallist.all_num = res.tab_totals.all_num
                    this.totallist.arrive_num = res.tab_totals.arrive_num
                    this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                    this.totallist.unarrive_num = res.tab_totals.unarrive_num
                    this.UnarriveList = res.list
                    for (let i = 0; i < this.UnarriveList.length; i++) {
                        this.$set(this.UnarriveList[i], 'show', false)
                    }
                    this.total = res.total
                    this.loading = false
                })
            },
            Submits(e) {
                if (!e) return false
                const startTime = e[0] || ''
                const endTime = e[1] || ''
                const nowDay = dayjs(this.nowDayTime).format('YYYY-MM-DD') // 当天
                const nowMonthStart = dayjs(this.yesterdayT).format('YYYY-MM-DD')
                const nowMonthEnd = dayjs(this.yesterdays).format('YYYY-MM-DD')
                const nowWeekStart = dayjs(this.yesterday).format('YYYY-MM-DD')
                const nowWeekEnd = dayjs(this.yestweek).format('YYYY-MM-DD')
                if (startTime === nowDay && endTime === nowDay) {
                    this.phone = '1'
                    this.advance = '1'
                } else if (startTime === nowMonthStart && endTime === nowMonthStart) {
                    this.BackTo = '2'
                    this.phone = '2'
                } else if (startTime === nowMonthEnd && endTime === nowMonthEnd) {
                    this.advance = '4'
                } else if (startTime === nowDay && endTime === nowWeekStart) {
                    this.advance = '3'
                } else if (startTime === nowWeekEnd && endTime === nowMonthStart) {
                    this.BackTo = '5'
                } else {
                    this.BackTo = ''
                    this.phone = ''
                    this.advance = ''
                }
                this.e = e
                if (this.name === '2') {
                    this.loading = true
                    const config = {
                        edit_type: '1',
                        start_time: e[0],
                        end_time: e[1],
                        page: this.realData.page,
                        pageSize: this.realData.pageSize,
                        keywords: this.createData.keywords || '',
                        outpatient_type_id: this.createData.outpatient_type_id || '',
                        belong_member_id: this.createData.belong_assistant_id || '',
                        fault_diagnosis_type: this.realData.fault_diagnosis_type
                    }
                    GetArriveList(config).then(res => {
                        this.totallist.all_num = res.tab_totals.all_num
                        this.totallist.arrive_num = res.tab_totals.arrive_num
                        this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                        this.totallist.unarrive_num = res.tab_totals.unarrive_num
                        this.beenList = res.list
                        for (let i = 0; i < this.beenList.length; i++) {
                            this.$set(this.beenList[i], 'show', false)
                        }
                        this.beenList.total = res.total
                        this.loading = false
                    })
                } else if (this.name === '3') {
                    this.loading = true
                    const config = {
                        edit_type: '1',
                        start_time: e[0],
                        end_time: e[1],
                        page: this.realData.page,
                        pageSize: this.realData.pageSize,
                        keywords: this.createData.keywords || '',
                        outpatient_type_id: this.createData.outpatient_type_id || '',
                        belong_member_id: this.createData.belong_assistant_id || '',
                        fault_diagnosis_type: this.realData.fault_diagnosis_type
                    }
                    GetOrderArriveList(config).then(res => {
                        this.totallist.all_num = res.tab_totals.all_num
                        this.totallist.arrive_num = res.tab_totals.arrive_num
                        this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                        this.totallist.unarrive_num = res.tab_totals.unarrive_num
                        this.OrderList = res.list
                        for (let i = 0; i < this.OrderList.length; i++) {
                            this.$set(this.OrderList[i], 'show', false)
                        }
                        this.total = res.total
                        this.loading = false
                    })
                } else if (this.name === '4') {
                    this.loading = true
                    const config = {
                        edit_type: '1',
                        start_time: e[0],
                        end_time: e[1],
                        page: this.realData.page,
                        pageSize: this.realData.pageSize,
                        keywords: this.createData.keywords || '',
                        outpatient_type_id: this.createData.outpatient_type_id || '',
                        belong_member_id: this.createData.belong_assistant_id || '',
                        effect_type_id: this.createData.effect_type_id || ''
                    }
                    GetUnarriveList(config).then(res => {
                        this.totallist.all_num = res.tab_totals.all_num
                        this.totallist.arrive_num = res.tab_totals.arrive_num
                        this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                        this.totallist.unarrive_num = res.tab_totals.unarrive_num
                        this.UnarriveList = res.list
                        for (let i = 0; i < this.UnarriveList.length; i++) {
                            this.$set(this.UnarriveList[i], 'show', false)
                        }
                        this.total = res.total
                        this.loading = false
                    })
                } else if (this.name === '1') {
                    // this.createData
                    this.realData.start_time = e
                    this.getData()
                }
            },
            resetData() {
                if (this.createData.keywords !== '') {
                    this.createData.start_time = ''
                    this.createData.end_time = ''
                    this.createData.belong_assistant_id = ''
                    this.createData.outpatient_type_id = ''
                    this.createData.effect_type_id = ''
                    this.createData.risk_type_id = ''
                    this.createData.clinic_id = ''
                    this.createData.clinic_assess_id = ''
                    this.createData.body_parts_ids = []
                    this.createData.tags_ids = []
                }
                this.createData.page = 1
                this.createData.pageSize = 10

                for (let key in this.createData) {
                    this.realData[key] = this.createData[key]
                }
                this.getData()
            },
            getBeen() {
                if (this.start_time[0] !== undefined && this.start_time[0] !== '') {
                    this.start_time = [dayjs(this.start_time[0]).format('YYYY-MM-DD'), dayjs(this.start_time[1]).format('YYYY-MM-DD')]
                } else {
                    this.start_time = ['', '']
                }
                this.loading = true
                const config = {
                    edit_type: '1',
                    start_time: this.start_time[0],
                    end_time: this.start_time[1],
                    page: this.realData.page,
                    clinic_id: this.createData.clinic_id,
                    pageSize: this.realData.pageSize,
                    keywords: this.createData.keywords || '',
                    outpatient_type_id: this.createData.outpatient_type_id || '',
                    belong_member_id: this.createData.belong_assistant_id || '',
                    sort_last_revisiting_type: this.realData.sort_last_revisiting_type,
                    sort_next_revisiting_type: this.realData.sort_next_revisiting_type,
                    sort_last_callback_type: this.realData.sort_last_callback_type,
                    sort_next_callback_type: this.realData.sort_next_callback_type,
                    sort_revisiting_type: this.realData.sort_revisiting_type,
                    sort_callback_type: this.realData.sort_callback_type,
                    sort_missed_type: this.realData.sort_missed_type,
                    fault_diagnosis_type: this.realData.fault_diagnosis_type

                }
                GetArriveList(config).then(res => {
                    this.totallist.all_num = res.tab_totals.all_num
                    this.totallist.arrive_num = res.tab_totals.arrive_num
                    this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                    this.totallist.unarrive_num = res.tab_totals.unarrive_num
                    this.beenList = res.list
                    for (let i = 0; i < this.beenList.length; i++) {
                        this.$set(this.beenList[i], 'show', false)
                    }
                    this.beenList.total = res.total
                    this.loading = false
                })
            },
            // 获取数据
            getData() {
                this.loading = true
                let sendData = JSON.parse(JSON.stringify(this.realData))
                if (sendData.start_time[0] !== undefined && sendData.start_time[0] !== '') {
                    sendData.end_time = dayjs(sendData.start_time[1]).format('YYYY-MM-DD')
                    sendData.start_time = dayjs(sendData.start_time[0]).format('YYYY-MM-DD')
                } else {
                    sendData.start_time = ''
                    sendData.end_time = ''
                }
                sendData.belong_member_id = sendData.belong_assistant_id
                delete sendData.belong_assistant_id
                sendData.body_parts_ids = sendData.body_parts_ids.length > 0 ? sendData.body_parts_ids.join(',') : ''
                sendData.tags_ids = sendData.tags_ids.length > 0 ? sendData.tags_ids.join(',') : ''
                serveList(sendData).then(res => {
                    this.totallist.all_num = res.tab_totals.all_num
                    this.totallist.arrive_num = res.tab_totals.arrive_num
                    this.totallist.order_arrive_num = res.tab_totals.order_arrive_num
                    this.totallist.unarrive_num = res.tab_totals.unarrive_num
                    this.total = res.total
                    this.data = res.list
                    for (let i = 0; i < this.data.length; i++) {
                        this.$set(this.data[i], 'show', false)
                    }
                    this.typeList = res.condition.outpatient_type_list;
                    this.labelList = res.condition.tags_list;
                    if (this.baseInfo.body_parts_list.length === 0 &&
                        this.baseInfo.clinic_assess_list.length === 0 &&
                        this.baseInfo.effect_type_list.length === 0 &&
                        this.baseInfo.member_list.length === 0 &&
                        this.baseInfo.outpatient_type_list.length === 0 &&
                        this.baseInfo.risk_type_list.length === 0 &&
                        this.baseInfo.tags_list.length === 0) {
                        this.baseInfo = res.condition
                    }
                }).finally(() => {
                    this.loading = false
                })
            },
            // 切换分页
            handleChangePage(e) {
                this.realData.page = e
                for (let key in this.createData) {
                    this.createData[key] = this.realData[key]
                }
                if (this.name === '1') {
                    this.getData()
                } else if (this.name === '2') {
                    this.getBeen()
                } else if (this.name === '3') {
                    this.GetOrder()
                } else if (this.name === '4') {
                    this.GetUnarrive()
                }
            },
            handleDetailPatient(row) {
                this.patientId = row.id
                this.showTetailDrawer = true
                // this.$store.commit('admin/page/setPatientDetail', { patientId: row.id, edit_type: 1 })
                // this.$router.push('/patient/detail')
            },
            // 排序
            handleChangeSort(column) {
                this.realData.sort_next_revisiting_type = 0
                this.realData.sort_last_callback_type = 0
                this.realData.sort_next_callback_type = 0
                this.realData.sort_revisiting_type = 0
                this.realData.sort_missed_type = 0
                this.realData.sort_callback_type = 0
                this.realData.sort_last_revisiting_type = 0
                switch (column.key) {
                    case 'last_revisiting_time_str':
                        column.order === 'asc' ? this.realData.sort_last_revisiting_type = 1 : column.order === 'normal' ? this.realData.sort_last_revisiting_type = 0 : this.realData.sort_last_revisiting_type = 2
                        break;
                    case 'next_revisiting_time_str':
                        column.order === 'asc' ? this.realData.sort_next_revisiting_type = 1 : column.order === 'normal' ? this.realData.sort_next_revisiting_type = 0 : this.realData.sort_next_revisiting_type = 2
                        break;
                    case 'last_callback_time_str':
                        column.order === 'asc' ? this.realData.sort_last_callback_type = 1 : column.order === 'normal' ? this.realData.sort_last_callback_type = 0 : this.realData.sort_last_callback_type = 2
                        break;
                    case 'next_callback_time_str':
                        column.order === 'asc' ? this.realData.sort_next_callback_type = 1 : column.order === 'normal' ? this.realData.sort_next_callback_type = 0 : this.realData.sort_next_callback_type = 2
                        break;
                    case 'revisiting_count':
                        column.order === 'asc' ? this.realData.sort_revisiting_type = 1 : column.order === 'normal' ? this.realData.sort_revisiting_type = 0 : this.realData.sort_revisiting_type = 2
                        break;
                    case 'missed_days':
                        column.order === 'asc' ? this.realData.sort_missed_type = 1 : column.order === 'normal' ? this.realData.sort_missed_type = 0 : this.realData.sort_missed_type = 2
                        break;
                    case 'callback_count':
                        column.order === 'asc' ? this.realData.sort_callback_type = 1 : column.order === 'normal' ? this.realData.sort_callback_type = 0 : this.realData.sort_callback_type = 2
                        break;
                }
                for (let key in this.createData) {
                    this.createData[key] = this.realData[key]
                }
                if (this.name === '1') {
                    this.getData()
                } else if (this.name === '2') {
                    this.getBeen()
                } else if (this.name === '3') {
                    this.GetOrder()
                } else {
                    this.GetUnarrive()
                }
            },
            // 编辑
            handleOpenDrawer(id) {
                this.$refs.editPatient.handleOpenDrawer(id, 1)
            },
            // 回访
            handleOpenSubmit(row) {
                this.$refs.editModel.handleShow(row, this.typeList, this.labelList, 1)
            },
            // 切换分页条数
            handleChangePageSize(e) {
                this.realData.pageSize = e
                for (let key in this.createData) {
                    this.createData[key] = this.realData[key]
                }
                if (this.name === '1') {
                    this.getData()
                } else if (this.name === '2') {
                    this.getBeen()
                } else if (this.name === '3') {
                    this.GetOrder()
                } else if (this.name === '4') {
                    this.GetUnarrive()
                }
            },
            // 提交
            handleSubmit(type) {
                if (type === 1) {
                    this.$refs.form.resetFields()
                    this.createData.start_time = ''
                    this.createData.end_time = ''
                    this.createData.belong_assistant_id = ''
                    this.createData.outpatient_type_id = ''
                    this.createData.effect_type_id = ''
                    this.createData.risk_type_id = ''
                    this.createData.clinic_id = ''
                    this.createData.clinic_assess_id = ''
                    this.createData.body_parts_ids = []
                    this.createData.tags_ids = []
                }
                if (this.createData.keywords !== '') {
                    this.createData.start_time = ''
                    this.createData.end_time = ''
                    this.createData.belong_assistant_id = ''
                    this.createData.outpatient_type_id = ''
                    this.createData.effect_type_id = ''
                    this.createData.risk_type_id = ''
                    this.createData.clinic_assess_id = ''
                    this.createData.body_parts_ids = []
                    this.createData.tags_ids = []
                }
                this.createData.page = 1
                this.createData.pageSize = 10
                for (let key in this.createData) {
                    this.realData[key] = this.createData[key]
                }
                this.start_time = this.e
                this.getData()
            },
            handleSubmits(type) {
                if (this.name === '2') {
                    if (type === 1) {
                        this.$refs.form.resetFields()
                    }
                    if (this.createData.keywords !== '') {
                        this.start_time = ''
                        this.createData.belong_assistant_id = ''
                        this.createData.outpatient_type_id = ''
                    }
                    this.createData.page = 1
                    this.createData.pageSize = 10
                    for (let key in this.createData) {
                        this.realData[key] = this.createData[key]
                    }
                    this.getBeen()
                } else if (this.name === '1') {
                    if (type === 1) {
                        this.$refs.form.resetFields()
                    }
                    this.resetData()

                    // if (this.createData.keywords !== '') {
                    //     this.createData.start_time = ''
                    //     this.createData.end_time = ''
                    //     this.createData.belong_assistant_id = ''
                    //     this.createData.outpatient_type_id = ''
                    //     this.createData.effect_type_id = ''
                    //     this.createData.risk_type_id = ''
                    //     this.createData.clinic_assess_id = ''
                    //     this.createData.body_parts_ids = []
                    //     this.createData.tags_ids = []
                    // }
                    // this.createData.page = 1
                    // this.createData.pageSize = 10
                    // for (let key in this.createData) {
                    //     this.realData[key] = this.createData[key]
                    // }

                    // this.getData()
                } else if (this.name === '3') {
                    if (type === 1) {
                        this.$refs.form.resetFields()
                    }
                    if (this.createData.keywords !== '') {
                        this.start_time = ''
                        this.createData.belong_assistant_id = ''
                        this.createData.outpatient_type_id = ''
                    }
                    this.createData.page = 1
                    this.createData.pageSize = 10
                    for (let key in this.createData) {
                        this.realData[key] = this.createData[key]
                    }
                    this.GetOrder()
                } else if (this.name === '4') {
                    if (type === 1) {
                        this.$refs.form.resetFields()
                    }
                    if (this.createData.keywords !== '') {
                        this.start_time = ''
                        this.createData.belong_assistant_id = ''
                        this.createData.outpatient_type_id = ''
                        this.createData.effect_type_id = ''
                    }
                    this.createData.page = 1
                    this.createData.pageSize = 10
                    for (let key in this.createData) {
                        this.realData[key] = this.createData[key]
                    }
                    this.GetUnarrive()
                }
            },
            closeEdit(val) {
                if (val) {
                    this.getData();
                }
            },
            modeStatus() {
                this.disabledStatus = !this.disabledStatus
                if (!this.disabledStatus) {
                    this.createData.risk_type_id = ''
                    this.createData.clinic_assess_id = ''
                    this.createData.body_parts_ids = []
                    this.createData.tags_ids = []
                }
            }
        }
    }
</script>
<style scoped lang="less">
    .blueStatus {
        line-height: 20px;
        background: #e6fffb;
        border-color: #87e8de;
        font-size: 12px;
        color: #13c2c2 !important;
    }

    .modeLeft {
        margin-left: 10px;
    }

    /deep/.ivu-table {
        min-height: 200px;
    }
</style>